﻿/*
worker 线程，在此线程完成与主线程不相关的操作
*/

#ifndef WORKER_H
#define WORKER_H
#include <QObject>
#include <QDebug>
#include <QThread>
#include <QString>

class Worker:public QObject
{
    Q_OBJECT
//public:
//    Worker(QObject *parent = nullptr){}

public slots:
    //doWork 定义了线程要执行的操作
    void doWork(const QString &parameter)
    {
        qDebug() << "receive the execute signal--";
        qDebug() << " worker current thread ID:" << QThread::currentThreadId();

        //循环一百万次
        QString result = "123456789";


        //发送结束信号
        qDebug() << " worker finish the work and sent the resultReady signal \n";
        emit resultReady(result);

    }

//线程完成工作时发送的信号
signals:
    void resultReady(const QString &result);
};

#endif // WORKER_H
